package com.css.fxfzmhwz.zcpt.sys.service.impl;

import com.css.fxfzmhwz.zcpt.sys.service.SysMenuService;
import com.css.fxfzmhwz.util.RestTemplateUtil;
import org.slw.common.helper.PropsHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

@Service
public class SysMenuServiceImpl implements SysMenuService {

    @Autowired
    private  RestTemplateUtil restTemplateUtil;


    @Override
    public String getMenuListByUserId(String userId) {
        //读取配置文件
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String sysId = configGroup.getProperty("app.system.id");
        String url = configGroup.getProperty("baseRestUrl") + "/smenu_dzj/getMenusByUserId?userId="+userId+"&sysId="+sysId;
        Map<String, Object> paramMap = new HashMap<>(2);
        paramMap.put("userId",userId);
        paramMap.put("sysId",sysId);
        ResponseEntity<String> responseEntity = restTemplateUtil.sendHttpRequest(url, paramMap);
        return  responseEntity.getBody();
    }
}
